package com.inspsys.algorithms.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.inspsys.common.annotation.Log;
import com.inspsys.common.core.controller.BaseController;
import com.inspsys.common.core.domain.AjaxResult;
import com.inspsys.common.enums.BusinessType;
import com.inspsys.algorithms.domain.AlgorithmsAnalysis;
import com.inspsys.algorithms.service.IAlgorithmsAnalysisService;
import com.inspsys.common.utils.poi.ExcelUtil;
import com.inspsys.common.core.page.TableDataInfo;

/**
 * 数据分析Controller
 * 
 * @author inspsys
 * @date 2025-01-09
 */
@RestController
@RequestMapping("/algorithms/analysis")
public class AlgorithmsAnalysisController extends BaseController
{
    @Autowired
    private IAlgorithmsAnalysisService algorithmsAnalysisService;

    /**
     * 查询数据分析列表
     */
    @PreAuthorize("@ss.hasPermi('algorithms:analysis:list')")
    @GetMapping("/list")
    public TableDataInfo list(AlgorithmsAnalysis algorithmsAnalysis)
    {
        startPage();
        List<AlgorithmsAnalysis> list = algorithmsAnalysisService.selectAlgorithmsAnalysisList(algorithmsAnalysis);
        return getDataTable(list);
    }

    /**
     * 导出数据分析列表
     */
    @PreAuthorize("@ss.hasPermi('algorithms:analysis:export')")
    @Log(title = "数据分析", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AlgorithmsAnalysis algorithmsAnalysis)
    {
        List<AlgorithmsAnalysis> list = algorithmsAnalysisService.selectAlgorithmsAnalysisList(algorithmsAnalysis);
        ExcelUtil<AlgorithmsAnalysis> util = new ExcelUtil<AlgorithmsAnalysis>(AlgorithmsAnalysis.class);
        util.exportExcel(response, list, "数据分析数据");
    }

    /**
     * 获取数据分析详细信息
     */
    @PreAuthorize("@ss.hasPermi('algorithms:analysis:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(algorithmsAnalysisService.selectAlgorithmsAnalysisById(id));
    }

    /**
     * 新增数据分析
     */
    @PreAuthorize("@ss.hasPermi('algorithms:analysis:add')")
    @Log(title = "数据分析", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AlgorithmsAnalysis algorithmsAnalysis)
    {
        return toAjax(algorithmsAnalysisService.insertAlgorithmsAnalysis(algorithmsAnalysis));
    }

    /**
     * 修改数据分析
     */
    @PreAuthorize("@ss.hasPermi('algorithms:analysis:edit')")
    @Log(title = "数据分析", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AlgorithmsAnalysis algorithmsAnalysis)
    {
        return toAjax(algorithmsAnalysisService.updateAlgorithmsAnalysis(algorithmsAnalysis));
    }

    /**
     * 删除数据分析
     */
    @PreAuthorize("@ss.hasPermi('algorithms:analysis:remove')")
    @Log(title = "数据分析", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(algorithmsAnalysisService.deleteAlgorithmsAnalysisByIds(ids));
    }
}
